package source.model;

import source.model.type.GameObjectType;
import source.events.action.Action;

/**
 * Represents attributes and behaviors common to all Entities (bases, units, etc.)
 * @author Tristan
 *
 */
public abstract class Entity implements GameObject{
	private final GameObjectType gameObjectType;
	private final ObjectID oid;
	private boolean isValid = true;
	
	public Entity(GameObjectType gameObjectType, int id){
		this.gameObjectType = gameObjectType;
		oid = new ObjectID( gameObjectType.getId() + "." + id );
	}
	

	public boolean isValid() {
		return isValid;
	}
	
	public ObjectID objectID() {
		return oid;
	}
	
	public GameObjectType objectType() {
		return gameObjectType;
	}
	
	public void invalidate(){
		isValid = false;
	}
	
	public void instantDeath() {
		isValid = false;
	}
	
	public abstract Action newTurn();

	public abstract boolean modHealth(int modHealth);
	
	public java.util.Hashtable<String, String> getViewData()
	{
		java.util.Hashtable<String, String> viewData = new java.util.Hashtable<String, String>();
		
		viewData.put("Object ID", oid.getID());
		viewData.put("Game Object Type", gameObjectType.name());
		viewData.put("Upkeep", Integer.toString(this.getUpkeep()));
		viewData.put("Armor", Integer.toString(this.armor()));
		viewData.put("Offensive Damage", Integer.toString(this.oDamage()));
		viewData.put("Defensive Damage", Integer.toString(this.dDamage()));
		
		return viewData;
	}
	
	public abstract int getUpkeep();
	

	
	public abstract int armor();
	public abstract int oDamage();
	public abstract int dDamage();
	
}

